cmake_minimum_required(VERSION 3.15)

set(PROJECT_NAME min-x86-elf)
project(${PROJECT_NAME}
        VERSION 1.0.0
        LANGUAGES C
        )

include_directories(inc)
aux_source_directory(src/ APPS_SRC_C)

set(LINKER_SCRIPT "script.ld")
get_filename_component(LINKER_SCRIPT_ABS "${LINKER_SCRIPT}" ABSOLUTE)

set(PROJECT_SRC_C ${APPS_SRC_C} main.c)
add_executable(${PROJECT_NAME} ${PROJECT_SRC_C})


target_compile_options(${PROJECT_NAME} PRIVATE 
    -m32
    -ffreestanding 
    -fno-builtin 
    -nodefaultlibs
    -fno-pic 
    -fno-pie
    -nostdlib
    -static 
    -g
    )
target_link_options(${PROJECT_NAME} PRIVATE 
    -m32
    -nostdlib
    -static 
    -no-pie               # 非位置无关可执行文件
    -T${LINKER_SCRIPT_ABS}
    )
